package hibernate.jaiku.dao.imp;

import hibernate.jaiku.dao.ComentarioDao;
import hibernate.jaiku.modelo.Comentario;
import hibernate.jaiku.utils.HibernateUtil;

import org.hibernate.Session;
import org.hibernate.Transaction;


public class ComentarioHibernate implements ComentarioDao {

	public void nuevoComentario(Comentario comentario) throws Exception {

		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction tx = null;
		
		try {
			tx = session.beginTransaction();
			session.save(comentario);
			tx.commit();
		} catch (Exception e) {
			if (tx != null)
				tx.rollback();
			throw e;
		} finally {
			session.close();
		}

	}

}
